package com.aspose.cells;

class zfe {
   static double a(double[] var0, int var1, double var2) {
      int var4 = com.aspose.cells.b.a.za.a(var0, 0, var1, var2);
      if (var4 < 0) {
         var4 = -var4 - 2;
         return ((double)var4 + (var2 - var0[var4]) / (var0[var4 + 1] - var0[var4])) / (double)(var1 - 1);
      } else {
         if (var4 > 0 && var0[var4 - 1] == var2) {
            --var4;

            while(var4 > 0 && var0[var4 - 1] == var2) {
               --var4;
            }
         }

         return (double)var4 / (double)(var1 - 1);
      }
   }

   static double b(double[] var0, int var1, double var2) {
      int var4 = com.aspose.cells.b.a.za.a(var0, 0, var1, var2);
      if (var4 < 0) {
         var4 = -var4 - 2;
         return ((double)var4 + 1.0D + (var2 - var0[var4]) / (var0[var4 + 1] - var0[var4])) / (double)(var1 + 1);
      } else {
         if (var4 > 0 && var0[var4 - 1] == var2) {
            --var4;

            while(var4 > 0 && var0[var4 - 1] == var2) {
               --var4;
            }
         }

         return (double)(var4 + 1) / (double)(var1 + 1);
      }
   }

   static double a(double[] var0, double var1) {
      int var3 = (int)var1;
      double var4 = var1 - (double)var3;
      return var4 == 0.0D ? var0[var3] : (1.0D - var4) * var0[var3] + var4 * var0[var3 + 1];
   }

   public static zagu a(double var0, double var2, double var4, boolean var6) {
      if (var0 >= 0.0D && var2 >= 1.0D && var4 >= 1.0D && var2 < 1.0E10D && var4 < 1.0E10D) {
         if (var0 == 0.0D) {
            return new zyy(1.0D);
         } else {
            try {
               return a(var4 / (var4 + var2 * var0), var4 / 2.0D, var2 / 2.0D, 0.0D, 1.0D, var6);
            } catch (Exception var8) {
               return zze.a;
            }
         }
      } else {
         return zze.a;
      }
   }

   public static zagu a(double var0, double var2, double var4, double var6, double var8, boolean var10) {
      if (var0 >= var6 && var0 <= var8 && var8 > var6 && var2 > 0.0D && var4 > 0.0D) {
         double var11;
         if (var10) {
            var0 = (var0 - var6) / (var8 - var6);
            var11 = zcl.a(var0, var2, var4);
         } else {
            var11 = zcl.b(var0, var2, var4, var6, var8);
         }

         return (zagu)(!Double.isNaN(var11) && !Double.isInfinite(var11) ? new zyy(var11) : zze.a);
      } else {
         return zze.a;
      }
   }

   public static zagu a(double var0, double var2, double var4, double var6, double var8) {
      if (var0 > 0.0D && var0 <= 1.0D && var2 > 0.0D && var4 > 0.0D && var8 > var6) {
         double var10 = 0.0D;
         var10 = zcl.c(var0, var2, var4);
         var10 = var10 * (var8 - var6) + var6;
         return new zyy(var10);
      } else {
         return zze.a;
      }
   }

   public static zagu a(double var0, double var2, double var4) {
      boolean var6 = true;
      boolean[] var7 = new boolean[]{var6};
      double var8 = zuz.a(var0, var2, var4, var7);
      var6 = var7[0];
      return (zagu)(var6 ? zze.a : new zyy(var8));
   }

   public static zagu a(double var0, double var2) {
      if (var0 > 0.0D && var0 <= 1.0D && var2 <= 1.0E10D && var2 >= 1.0D) {
         try {
            zaom var4 = new zaom(var2);
            if (var4.a(0.0D, var0, 0.5D * var2, var2)) {
               return new zyy(var4.a());
            }
         } catch (Exception var5) {
            ;
         }

         return zze.a;
      } else {
         return zze.a;
      }
   }

   public static zagu a(double var0, double var2, int var4) {
      if (var0 >= 0.0D && var2 >= 1.0D && var4 <= 2 && var4 >= 1) {
         try {
            zakm var5 = new zakm(var2);
            double var6;
            if (var0 < 5.0D) {
               var6 = var5.a(0.0D, var0, 1.0E-20D);
            } else {
               var6 = var5.a(0.0D, 5.0D, 1.0E-20D) + var5.a(5.0D, var0, 1.0E-20D);
            }

            return new zyy((0.5D - var6) * (double)var4);
         } catch (Exception var8) {
            return zze.a;
         }
      } else {
         return zze.a;
      }
   }

   public static zagu b(double var0, double var2) {
      if (var2 >= 1.0D && var0 >= 0.0D && var0 <= 1.0D) {
         if (var0 == 0.0D) {
            return new zyy(1.0E7D);
         } else if (var0 == 1.0D) {
            return new zyy(0.0D);
         } else {
            try {
               zaoo var4 = new zaoo(var2, var0);
               if (var4.a(1.0D, 100, 1.0E-12D)) {
                  return new zyy(var4.a());
               }
            } catch (Exception var5) {
               ;
            }

            return zze.a;
         }
      } else {
         return zze.a;
      }
   }

   public static zagu c(double var0, double var2) {
      if (var0 >= 0.0D && var2 >= 1.0D && var2 <= 1.0E10D) {
         try {
            return new zyy(1.0D - zabx.a(var2 * 0.5D, var0 * 0.5D));
         } catch (Exception var5) {
            return zze.a;
         }
      } else {
         return zze.a;
      }
   }

   public static zagu a(double var0, double var2, boolean var4) {
      if (var0 >= 0.0D && var2 >= 1.0D && var2 <= 1.0E10D) {
         try {
            return new zyy(zabx.a(var2 * 0.5D, var0 * 0.5D));
         } catch (Exception var6) {
            return zze.a;
         }
      } else {
         return zze.a;
      }
   }

   static zagu a(int var0, double var1, double var3) {
      if (var0 >= 0 && var1 >= 0.0D && var1 <= 1.0D && var3 >= 0.0D && var3 <= 1.0D) {
         boolean var5 = false;
         double var6 = 0.0D;

         int var8;
         for(var8 = 0; var8 <= var0; ++var8) {
            var6 += zbof.a(var0, var8) * Math.pow(var1, (double)var8) * Math.pow(1.0D - var1, (double)(var0 - var8));
            if (var6 >= var3) {
               break;
            }
         }

         var8 = var8 > var0 ? var0 : var8;
         return new zyy((double)var8);
      } else {
         return zze.a;
      }
   }

   public static zagu a(int var0, int var1, double var2, boolean var4) {
      if (var0 >= 0 && var0 <= var1 && var2 >= 0.0D && var2 <= 1.0D) {
         double var5 = 0.0D;

         try {
            if (var4) {
               for(int var7 = var0; var7 >= 0; --var7) {
                  var5 += zbof.a(var1, var7) * Math.pow(var2, (double)var7) * Math.pow(1.0D - var2, (double)(var1 - var7));
               }
            } else {
               var5 = zbof.a(var1, var0) * Math.pow(var2, (double)var0) * Math.pow(1.0D - var2, (double)(var1 - var0));
            }

            return new zyy(var5);
         } catch (Exception var8) {
            return zze.a;
         }
      } else {
         return zze.a;
      }
   }

   public static zagu b(double var0, double var2, double var4) {
      if (var0 >= 0.0D && var0 <= 1.0D && var2 > 0.0D && var4 > 0.0D) {
         try {
            return new zyy(zabx.b(var0, var2, var4));
         } catch (Exception var7) {
            return new zyy(0.0D);
         }
      } else {
         return zze.a;
      }
   }

   static zagu a(double var0, double var2, double var4, double var6) {
      if (var0 >= 0.0D && var0 <= (var2 < var4 ? var2 : var4) && var2 >= 0.0D && var2 <= var6 && var4 >= 0.0D && var4 <= var6 && var6 >= 0.0D) {
         var0 = Math.floor(var0);
         var2 = Math.floor(var2);
         var4 = Math.floor(var4);
         var6 = Math.floor(var6);
         return new zyy(e(var4, var0) * e(var6 - var4, var2 - var0) / e(var6, var2));
      } else {
         return zze.a;
      }
   }

   static double b(double var0, double var2, double var4, boolean var6) {
      double var7 = Math.pow(var0 / var4, var2);
      var7 = Math.exp(-var7);
      return var6 ? 1.0D - var7 : var2 / Math.pow(var4, var2) * Math.pow(var0, var2 - 1.0D) * var7;
   }

   public static zagu c(double var0, double var2, double var4, boolean var6) {
      if (var0 >= 0.0D && var2 > 0.0D && var4 > 0.0D) {
         if (!var6) {
            return new zyy(zabx.c(var0, var2, var4));
         } else if (var0 <= 0.0D) {
            return zyy.a;
         } else {
            try {
               return new zyy(zabx.e(var2, var0 / var4));
            } catch (Exception var8) {
               return zze.a;
            }
         }
      } else {
         return zze.a;
      }
   }

   static double a(double[] var0, int var1, int var2, double var3, double var5) {
      double var7 = a(var0, var1, var2, 1);
      double var9 = (var7 - var3) / (var5 / Math.sqrt((double)(var2 - var1)));
      double var11 = 1.0D - zaor.b(var9);
      return var11;
   }

   static double a(double[] var0, int var1, int var2, double var3) {
      double var5 = a(var0, var1, var2, 1);
      double var7 = a(var0, 1, var2);
      double var9 = (var5 - var3) / Math.sqrt(var7 / (double)(var2 - var1));
      double var11 = 1.0D - zaor.b(var9);
      return var11;
   }

   static zagu a(double[] var0, double[] var1, int var2, int var3) {
      double var4 = 0.0D;
      double var6;
      if (var3 == 1) {
         var6 = b(var0, var1);
         var4 = (double)(var0.length - 1);
      } else if (var3 == 2) {
         var6 = a(var0, var1);
         var4 = (double)(var0.length + var1.length - 2);
      } else {
         double var8 = a(var0, 1, var0.length);
         double var10 = a(var1, 1, var1.length);
         double var12 = a(var0, 0, var0.length, 1);
         double var14 = a(var1, 0, var1.length, 1);
         var6 = a(var12, var14, var8, var10, var0.length, var1.length);
         var4 = a(var8, var0.length, var10, var1.length);
      }

      return a(var6, var4, var2);
   }

   private static double b(double[] var0, double[] var1) {
      double var2 = 0.0D;
      double var4 = 0.0D;
      double var6 = 0.0D;
      int var8 = var0.length;

      for(int var9 = 0; var9 < var8; ++var9) {
         var6 = var0[var9] - var1[var9];
         var2 += var6;
         var4 += var6 * var6;
      }

      double var11 = var2 / ((double)var8 * Math.sqrt(((double)var8 * var4 - var2 * var2) / (double)(var8 * var8 * (var8 - 1))));
      return Math.abs(var11);
   }

   static double a(double[] var0, double[] var1) {
      double var2 = a(var0, 0, var0.length, 1);
      double var4 = a(var1, 0, var1.length, 1);
      double var6 = a(var0, 1, var0.length, var1, 1, var1.length);
      double var8 = (var2 - var4) / Math.sqrt(var6 * (1.0D / (double)var0.length + 1.0D / (double)var1.length));
      return var8;
   }

   static double a(double var0, double var2, double var4, double var6, int var8, int var9) {
      return (var0 - var2) / Math.sqrt(var4 / (double)var8 + var6 / (double)var9);
   }

   private static double a(double var0, int var2, double var3, int var5) {
      return (var0 / (double)var2 + var3 / (double)var5) * (var0 / (double)var2 + var3 / (double)var5) / (var0 / (double)var2 * (var0 / (double)var2) / (double)(var2 - 1) + var3 / (double)var5 * (var3 / (double)var5) / (double)(var5 - 1));
   }

   static double a(double[] var0, int var1, int var2, double[] var3, int var4, int var5) {
      double var6 = a(var0, var1, var2);
      double var8 = a(var3, var4, var5);
      return ((double)(var2 - 1) * var6 + (double)(var5 - 1) * var8) / (double)(var2 + var5 - 2);
   }

   private static double a(double[] var0, int var1, int var2, int var3) {
      double var4 = 0.0D;

      for(int var6 = var1; var6 < var2; ++var6) {
         var4 += (var0[var6 * var3] - var4) / (double)(var6 - var1 + 1);
      }

      return var4;
   }

   private static double a(double[] var0, int var1, int var2) {
      double var3 = a(var0, 0, var2, var1);
      return b(var0, var1, var2, var3);
   }

   private static double b(double[] var0, int var1, int var2, double var3) {
      double var5 = c(var0, var1, var2, var3);
      return var5 * ((double)var2 / (double)(var2 - 1));
   }

   private static double c(double[] var0, int var1, int var2, double var3) {
      double var5 = 0.0D;

      for(int var7 = 0; var7 < var2; ++var7) {
         double var8 = var0[var7 * var1] - var3;
         var5 += (var8 * var8 - var5) / (double)(var7 + 1);
      }

      return var5;
   }

   private static double e(double var0, double var2) {
      return d(var0, var2) / d(var2, var2);
   }

   static double d(double var0, double var2) {
      double var4 = 1.0D;
      var0 = Math.floor(var0);
      var2 = Math.floor(var2);

      for(double var6 = var0; var6 > var0 - var2; --var6) {
         var4 *= var6;
      }

      return var4;
   }
}
